﻿using System.Text.Json.Serialization;

namespace Refit
{
    /// <summary>
    /// The object representing the details about a ValidationException caught by a service implementing RFC 7807.
    /// </summary>
    public class ProblemDetails
    {
        /// <summary>
        /// Collection of resulting errors for the request.
        /// </summary>
        public Dictionary<string, string[]> Errors { get; set; } =
            new Dictionary<string, string[]>();

        /// <summary>
        /// Collection of ProblemDetails extensions
        /// </summary>
        [JsonExtensionData]
        public IDictionary<string, object> Extensions { get; set; } =
            new Dictionary<string, object>(StringComparer.Ordinal);

        /// <summary>
        /// A URI reference that identifies the problem type.
        /// </summary>
        public string? Type { get; set; } = "about:blank";

        /// <summary>
        /// A short, human-readable summary of the problem type.
        /// </summary>
        public string? Title { get; set; }

        /// <summary>
        /// The HTTP status code generated by the origin server for this occurrence of the problem.
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// A human-readable explanation specific to this occurrence of the problem.
        /// </summary>
        public string? Detail { get; set; }

        /// <summary>
        /// A URI reference that identifies the specific occurrence of the problem.
        /// </summary>
        public string? Instance { get; set; }
    }
}
